OPC Studio User's Guide and Reference
ReadMultipleValues(IEasyUAClient,UAReadArguments[]) Method
Example 



OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA Namespace > IEasyUAClientExtension Class > ReadMultipleValues Method : ReadMultipleValues(IEasyUAClient,UAReadArguments[]) Method
The client object that will perform the operation.
Array of OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments. Array of argument objects specifying what to read from an OPC-UA server.
Reads values of multiple attributes. Reads values of multiple attributes, using array of argument objects as an input.
Syntax
'Declaration
 
<ExtensionAttribute()>
<ElementsNotNullAttribute()>
<NotNullAttribute()>
Public Overloads Shared Function ReadMultipleValues( _
   ByVal client As IEasyUAClient, _
   ByVal readArgumentsArray() As UAReadArguments _
) As ValueResult()
'Usage
 
Dim client As IEasyUAClient
Dim readArgumentsArray() As UAReadArguments
Dim value() As ValueResult
 
value = IEasyUAClientExtension.ReadMultipleValues(client, readArgumentsArray)
[Extension()]
[ElementsNotNull()]
[NotNull()]
public static ValueResult[] ReadMultipleValues( 
   IEasyUAClient client,
   UAReadArguments[] readArgumentsArray
)
[Extension()]
[ElementsNotNull()]
[NotNull()]
public:
static array<ValueResult^>^ ReadMultipleValues( 
   IEasyUAClient^ client,
   array<UAReadArguments^>^ readArgumentsArray
) 

Parameters

client
The client object that will perform the operation.
readArgumentsArray
Array of OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments. Array of argument objects specifying what to read from an OPC-UA server.

Return Value

Array of OpcLabs.BaseLib.OperationModel.ValueResult. Returns an array of value objects. Each object contains the actual value of an attribute. The indices of elements in the output array are the same as those in the input array, readArgumentsArray.
Exceptions
ExceptionDescription

A null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception.

Remarks

The status codes of attributes should be 'good'; otherwise, a OpcLabs.BaseLib.OperationModel.ValueResult.Value of that attribute is not valid, and OpcLabs.BaseLib.OperationModel.OperationResult.Exception contains a non-null exception.

The size of the input array will become the size of the output array. The element positions (indices) in the output array are the same as in the input array.

 

This is a multiple-operation method. In a properly written program, it does not throw any exceptions. You should therefore not put try/catch statements or similar constructs around calls to this method. The only exceptions thrown by this method are for usage errors, i.e. when your code violates the usage contract of the method, such as passing in invalid arguments or calling the method when the state of the object does not allow it. Any operation-related errors (i.e. errors that depend on external conditions that your code cannot reliably check) are indicated in the result objects returned by the method. For more information, see Multiple-operation Methods and Do not catch any exceptions with asynchronous or multiple-operation methods.
Example

.NET

.NET

// This example shows how to read the Value attributes of 3 different nodes at once. Using the same method, it is also possible 
// to read multiple attributes of the same node.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using OpcLabs.BaseLib.OperationModel;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples._EasyUAClient
{
    partial class ReadMultipleValues
    {
        public static void Main1()
        {
            UAEndpointDescriptor endpointDescriptor =
                "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
            // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
            // or "https://opcua.demo-this.com:51212/UA/SampleServer/"

            // Instantiate the client object.
            var client = new EasyUAClient();

            // Obtain values. By default, the Value attributes of the nodes will be read.
            ValueResult[] valueResultArray = client.ReadMultipleValues(new[]
                {
                    new UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10845"),
                    new UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10853"),
                    new UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10855")
                });

            // Display results.
            foreach (ValueResult valueResult in valueResultArray)
            {
                if (valueResult.Succeeded)
                    Console.WriteLine($"Value: {valueResult.Value}");
                else
                    Console.WriteLine($"*** Failure: {valueResult.ErrorMessageBrief}");
            }


            // Example output:
            //
            //Value: 8
            //Value: -8.06803E+21
            //Value: Strawberry Pig Banana Snake Mango Purple Grape Monkey Purple? Blueberry Lemon^            
        }
    }
}
# This example shows how to read the Value attributes of 3 different nodes at once. Using the same method, it is also possible 
# to read multiple attributes of the same node.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

#requires -Version 5.1
using namespace OpcLabs.EasyOpc.UA
using namespace OpcLabs.EasyOpc.UA.OperationModel

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUA.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUAComponents.dll"

[UAEndpointDescriptor]$endpointDescriptor =
    "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
# or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
# or "https://opcua.demo-this.com:51212/UA/SampleServer/"

# Instantiate the client object.
$client = New-Object EasyUAClient

# Obtain values. By default, the Value attributes of the nodes will be read.
$valueResultArray = $client.ReadMultipleValues([UAReadArguments[]]@(
        (New-Object UAReadArguments($endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10845")), 
        (New-Object UAReadArguments($endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10853")), 
        (New-Object UAReadArguments($endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10855"))
    ))

foreach ($valueResult in $valueResultArray) {
    if ($valueResult.Succeeded) {
        Write-Host "Value: $($valueResult.Value)"
    }
    else {
        Write-Host "*** Failure: $($valueResult.ErrorMessageBrief)"
    }
}


# Example output:
#
#Value: 8
#Value: -8.06803E+21
#Value: Strawberry Pig Banana Snake Mango Purple Grape Monkey Purple? Blueberry Lemon^            
# This example shows how to read the Value attributes of 3 different nodes at once. Using the same method, it is also possible
# to read multiple attributes of the same node.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc
import time

# Import .NET namespaces.
from OpcLabs.EasyOpc.UA import *
from OpcLabs.EasyOpc.UA.OperationModel import *


endpointDescriptor = UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:51210/UA/SampleServer')
# or 'http://opcua.demo-this.com:51211/UA/SampleServer' (currently not supported)
# or 'https://opcua.demo-this.com:51212/UA/SampleServer/'

# Instantiate the client object.
client = EasyUAClient()

# Obtain values. By default, the Value attributes of the nodes will be read.
valueResultArray = IEasyUAClientExtension.ReadMultipleValues(client, [
    UAReadArguments(endpointDescriptor, UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10845')),
    UAReadArguments(endpointDescriptor, UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10853')),
    UAReadArguments(endpointDescriptor, UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10855')),
    ])

# Display results.
for valueResult in valueResultArray:
    if valueResult.Succeeded:
        print('Value: ', valueResult.Value, sep='')
    else:
        print('*** Failure: ', valueResult.ErrorMessageBrief, sep='')

print()
print('Finished.')
' This example shows how to read the Value attributes of 3 different nodes at once. Using the same method, it is also possible 
' to read multiple attributes of the same node.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports System
Imports OpcLabs.BaseLib.OperationModel
Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.OperationModel

Namespace _EasyUAClient
    Partial Friend Class ReadMultipleValues
        Public Shared Sub Main1()

            ' Define which server we will work with.
            Dim endpointDescriptor As UAEndpointDescriptor =
                    "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
            ' or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
            ' or "https://opcua.demo-this.com:51212/UA/SampleServer/"

            ' Instantiate the client object
            Dim client = New EasyUAClient()

            ' Obtain values. By default, the Value attributes of the nodes will be read.
            Dim valueResultArray() As ValueResult = client.ReadMultipleValues(New UAReadArguments() _
               {
                   New UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10845"),
                   New UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10853"),
                   New UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10855")
               }
            )

            ' Display results
            For Each valueResult As ValueResult In valueResultArray
                If valueResult.Succeeded Then
                    Console.WriteLine("Value: {0}", valueResult.Value)
                Else
                    Console.WriteLine("*** Failure: {0}", valueResult.ErrorMessageBrief)
                End If
            Next valueResult

            ' Example output:
            '
            'Value: 8
            'Value: -8.06803E+21
            'Value: Strawberry Pig Banana Snake Mango Purple Grape Monkey Purple? Blueberry Lemon^            
        End Sub
    End Class
End Namespace
// This example shows how to read the Value attributes of 3 different nodes at once. Using the same method, it is also possible 
// to read multiple attributes of the same node.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using OpcLabs.BaseLib.OperationModel;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.AddressSpace;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples._EasyUAClient
{
    partial class ReadMultipleValues
    {
        public static void DataType()
        {
            UAEndpointDescriptor endpointDescriptor =
                "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
            // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
            // or "https://opcua.demo-this.com:51212/UA/SampleServer/"

            // Instantiate the client object.
            var client = new EasyUAClient();

            // Obtain values.
            ValueResult[] valueResultArray = client.ReadMultipleValues(new[]
                {
                    new UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10845", UAAttributeId.DataType),
                    new UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10853", UAAttributeId.DataType),
                    new UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10855", UAAttributeId.DataType)
                });

            // Display results.
            foreach (ValueResult valueResult in valueResultArray)
            {
                Console.WriteLine();

                if (valueResult.Succeeded)
                {
                    Console.WriteLine($"Value: {valueResult.Value}");
                    var dataTypeId = valueResult.Value as UANodeId;
                    if (!(dataTypeId is null))
                    {
                        Console.WriteLine($"Value.ExpandedText: {dataTypeId.ExpandedText}");
                        Console.WriteLine($"Value.NamespaceUriString: {dataTypeId.NamespaceUriString}");
                        Console.WriteLine($"Value.NamespaceIndex: {dataTypeId.NamespaceIndex}");
                        Console.WriteLine($"Value.NumericIdentifier: {dataTypeId.NumericIdentifier}");
                    }
                }
                else
                    Console.WriteLine($"*** Failure: {valueResult.ErrorMessageBrief}");
            }

            // Example output:
            //
            //Value: SByte
            //Value.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2
            //Value.NamespaceUriString: http://opcfoundation.org/UA/
            //Value.NamespaceIndex: 0
            //Value.NumericIdentifier: 2
            //
            //Value: Float
            //Value.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=10
            //Value.NamespaceUriString: http://opcfoundation.org/UA/
            //Value.NamespaceIndex: 0
            //Value.NumericIdentifier: 10
            //
            //Value: String
            //Value.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=12
            //Value.NamespaceUriString: http://opcfoundation.org/UA/
            //Value.NamespaceIndex: 0
            //Value.NumericIdentifier: 12
        }
    }
}
# This example shows how to read the Value attributes of 3 different nodes at once. Using the same method, it is also possible 
# to read multiple attributes of the same node.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

#requires -Version 5.1
using namespace OpcLabs.EasyOpc.UA
using namespace OpcLabs.EasyOpc.UA.AddressSpace
using namespace OpcLabs.EasyOpc.UA.OperationModel

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUA.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUAComponents.dll"

[UAEndpointDescriptor]$endpointDescriptor =
    "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
# or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
# or "https://opcua.demo-this.com:51212/UA/SampleServer/"

# Instantiate the client object.
$client = New-Object EasyUAClient

# Obtain values. 
$valueResultArray = $client.ReadMultipleValues([UAReadArguments[]]@(
        (New-Object UAReadArguments($endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10845", [UAAttributeId]::DataType)), 
        (New-Object UAReadArguments($endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10853", [UAAttributeId]::DataType)), 
        (New-Object UAReadArguments($endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10855", [UAAttributeId]::DataType))
    ))

foreach ($valueResult in $valueResultArray) {
    Write-Host

    if ($valueResult.Succeeded) {
        Write-Host "Value: $($valueResult.Value)"
        [UANodeId]$dataTypeId = $valueResult.Value;
        if ($dataTypeId -ne $null) {
            Write-Host "Value.ExpandedText: $($dataTypeId.ExpandedText)"
            Write-Host "Value.NamespaceUriString: $($dataTypeId.NamespaceUriString)"
            Write-Host "Value.NamespaceIndex: $($dataTypeId.NamespaceIndex)"
            Write-Host "Value.NumericIdentifier: $($dataTypeId.NumericIdentifier)"
        }
    }
    else {
        Write-Host "*** Failure: $($valueResult.ErrorMessageBrief)"
    }
}


# Example output:
#
#Value: SByte
#Value.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2
#Value.NamespaceUriString: http://opcfoundation.org/UA/
#Value.NamespaceIndex: 0
#Value.NumericIdentifier: 2
#
#Value: Float
#Value.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=10
#Value.NamespaceUriString: http://opcfoundation.org/UA/
#Value.NamespaceIndex: 0
#Value.NumericIdentifier: 10
#
#Value: String
#Value.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=12
#Value.NamespaceUriString: http://opcfoundation.org/UA/
#Value.NamespaceIndex: 0
#Value.NumericIdentifier: 12
# This example shows how to read the Value attributes of 3 different nodes at once. Using the same method, it is also
# possible to read multiple attributes of the same node.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc
import time

# Import .NET namespaces.
from OpcLabs.EasyOpc.UA import *
from OpcLabs.EasyOpc.UA.AddressSpace import *
from OpcLabs.EasyOpc.UA.OperationModel import *


endpointDescriptor = UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:51210/UA/SampleServer')
# or 'http://opcua.demo-this.com:51211/UA/SampleServer' (currently not supported)
# or 'https://opcua.demo-this.com:51212/UA/SampleServer/'

# Instantiate the client object.
client = EasyUAClient()

# Obtain values. By default, the Value attributes of the nodes will be read.
valueResultArray = IEasyUAClientExtension.ReadMultipleValues(client, [
    UAReadArguments(endpointDescriptor, UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10845'),
                    UAAttributeId.DataType),
    UAReadArguments(endpointDescriptor, UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10853'),
                    UAAttributeId.DataType),
    UAReadArguments(endpointDescriptor, UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10855'),
                    UAAttributeId.DataType),
    ])

# Display results.
for valueResult in valueResultArray:
    print()
    #
    if valueResult.Succeeded:
        print('Value: ', valueResult.Value, sep='')
        if isinstance(valueResult.Value, UANodeId):
            dataTypeId = valueResult.Value
            print('dataTypeId.ExpandedText: ', dataTypeId.ExpandedText, sep='')
            print('dataTypeId.NamespaceUriString: ', dataTypeId.NamespaceUriString, sep='')
            print('dataTypeId.NamespaceIndex: ', dataTypeId.NamespaceIndex, sep='')
            print('dataTypeId.NumericIdentifier: ', dataTypeId.NumericIdentifier, sep='')
    else:
        print('*** Failure: ', valueResult.ErrorMessageBrief, sep='')

print()
print('Finished.')
' This example shows how to read the Value attributes of 3 different nodes at once. Using the same method, it is also possible 
' to read multiple attributes of the same node.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Imports System
Imports OpcLabs.BaseLib.OperationModel
Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.AddressSpace
Imports OpcLabs.EasyOpc.UA.OperationModel

Namespace _EasyUAClient
    Partial Friend Class ReadMultipleValues
        Public Shared Sub DataType()

            ' Define which server we will work with.
            Dim endpointDescriptor As UAEndpointDescriptor =
                    "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
            ' or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
            ' or "https://opcua.demo-this.com:51212/UA/SampleServer/"

            ' Instantiate the client object
            Dim client = New EasyUAClient()

            ' Obtain values.
            Dim valueResultArray() As ValueResult = client.ReadMultipleValues(New UAReadArguments() _
               {
                   New UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10845", UAAttributeId.DataType),
                   New UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10853", UAAttributeId.DataType),
                   New UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10855", UAAttributeId.DataType)
               }
            )

            ' Display results
            For Each valueResult As ValueResult In valueResultArray
                Console.WriteLine()

                If valueResult.Succeeded Then
                    Console.WriteLine("Value: {0}", valueResult.Value)
                    Dim dataTypeId = CType(valueResult.Value, UANodeId)
                    If Not dataTypeId Is Nothing Then
                        Console.WriteLine("Value.ExpandedText: {0}", dataTypeId.ExpandedText)
                        Console.WriteLine("Value.NamespaceUriString: {0}", dataTypeId.NamespaceUriString)
                        Console.WriteLine("Value.NamespaceIndex: {0}", dataTypeId.NamespaceIndex)
                        Console.WriteLine("Value.NumericIdentifier: {0}", dataTypeId.NumericIdentifier)
                    End If
                Else
                    Console.WriteLine("*** Failure: {0}", valueResult.ErrorMessageBrief)
                End If
            Next valueResult

            ' Example output:
            '
            'Value: SByte
            'Value.ExpandedText: nsu = http : //opcfoundation.org/UA/ ;i=2
            'Value.NamespaceUriString: http : //opcfoundation.org/UA/
            'Value.NamespaceIndex: 0
            'Value.NumericIdentifier: 2
            '
            'Value: Float
            'Value.ExpandedText: nsu = http : //opcfoundation.org/UA/ ;i=10
            'Value.NamespaceUriString: http : //opcfoundation.org/UA/
            'Value.NamespaceIndex: 0
            'Value.NumericIdentifier: 10
            '
            'Value: String
            'Value.ExpandedText: nsu = http : //opcfoundation.org/UA/ ;i=12
            'Value.NamespaceUriString: http : //opcfoundation.org/UA/
            'Value.NamespaceIndex: 0
            'Value.NumericIdentifier: 12
        End Sub
    End Class
End Namespace
Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also